package com.nais.controllers;

import org.apache.commons.lang3.builder.ToStringBuilder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.nais.domain.City;
import com.nais.mapper.CityMapper;
import com.nais.mapper.EcSchoolMapper;

@Controller
public class HelloController {
    
	
	@Autowired
	private CityMapper cityMapper;
	
	@Autowired
	private EcSchoolMapper ecSchoolMapper;
	
    @ResponseBody
    @RequestMapping("/hello")
    public String hello() {
        return "Hello World";
    }

    @RequestMapping("db")
    @ResponseBody
    public String db(ModelMap map) {
        
    	
    	return ToStringBuilder.reflectionToString(ecSchoolMapper.selectByPrimaryKey(1));
    }
    
    @RequestMapping("/city")
    public String city(ModelMap map) {
    	City city = cityMapper.findByState("CA");
    	map.addAttribute("city", city);
    	return "city";
    }
    
    @RequestMapping("/test")
    @ResponseBody
    public String test(){
    	return "dsdsdsds";
    }

}